import 'dart:ffi';

import 'package:flutter/material.dart';



class textLuminescence extends StatefulWidget{
  String text;
  double fontSize;

  textLuminescence({
    required this.text,
    required this.fontSize
  });

  @override
  _textLuminescence createState(){
    return new _textLuminescence(text:text,fontSize:fontSize);
  }
}


class _textLuminescence  extends State<textLuminescence> with SingleTickerProviderStateMixin {
  String text;
  double fontSize;

  _textLuminescence({
    required this.text,
    required this.fontSize
  });

  late Animation<double> animation;
  late AnimationController controller;

  @override
  void initState() {
    super.initState();
    controller = AnimationController(duration: const Duration(seconds: 2), vsync: this);
    animation = CurvedAnimation(parent: controller, curve: Curves.easeIn)..addStatusListener((status) {
      if (status == AnimationStatus.completed) {
        controller.reverse();
      } else if (status == AnimationStatus.dismissed) {
        controller.forward();
      }
    });
    controller.forward();
  }

  void dispose() {
    controller.dispose();
    super.dispose();
  }

  Widget build(BuildContext context) {

    return Container(
      child: AnimatedLogo(animation: animation,text:text,fontSize:fontSize),
    );
  }
}

class AnimatedLogo extends AnimatedWidget {
  String text;
  double fontSize;

  AnimatedLogo({super.key, required Animation<double> animation,required this.text,
    required this.fontSize})
      : super(listenable: animation);

  // Make the Tweens static because they don't change.

  static final _blurRadiusTween = Tween<double>(begin: 0, end:50);

  @override
  Widget build(BuildContext context) {
    final animation = listenable as Animation<double>;
    return Text(text,style: TextStyle(fontSize: fontSize,decoration: TextDecoration.none,color: Color.fromRGBO(236, 243, 247, 1),fontWeight: FontWeight.bold,shadows: [
        Shadow(
          color: Color.fromRGBO(255, 255, 255, 1),
          offset: Offset(0, 0),
          blurRadius:  _blurRadiusTween.evaluate(animation),
        ),
      ]));
  }
}